package com.itheima.test;

import java.util.Scanner;

public class LoopTest3 {
    public static void main(String[] args) {
        //求质数
        //一个整数之能被 1 和它本身整数，就是质数，否则就是合数

        Scanner sc = new Scanner(System.in);
        System.out.print("请输入一个整数：");
        int number = sc.nextInt();
        boolean flag = true;
        if (number == 1 || number == 2) {
            System.out.println("是质数");
        } else {
            for (int i = 2; i < number / 2; i++) {
                if(number % i == 0){
                    flag = false;
                    System.out.println(number + "不是质数");
                    break;
                }
            }
            if (flag) System.out.println(number +"是质数");
        }
    }
}
